import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'common_image.dart';

const List<String> defaultImages = [
  "https://pic.netbian.com/uploads/allimg/230622/005957-168736679702b9.jpg",
  "https://pic.netbian.com/uploads/allimg/190513/204857-1557751737c7fb.jpg",
  "https://pic.netbian.com/uploads/allimg/190513/205404-1557752044afb2.jpg",
];
var imageWidth = 1202.0;
var imageHeight = 676.0;

class CommonSwiper extends StatelessWidget {
  final List<String> images;

  const CommonSwiper({Key? key, this.images = defaultImages}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    var height = MediaQuery.of(context).size.width / imageWidth * imageHeight;
    return SizedBox(
      height: height,
      child: Swiper(
        itemBuilder: (BuildContext context, int index) {
          return CommonImage(
            images[index],
            fit: BoxFit.fill,
          );
        },
        autoplay: true,
        itemCount: images.length,
        pagination: const SwiperPagination(),
        duration: 500,
        // control: const SwiperControl(),
      ),
    );
  }
}
